<template>
	<view class="container">
		<!-- <view class="title">
			新增标题：<textarea id="addtitle" adjust-position="true" auto-height="true"/>
		</view>

		<view class="content">
				新增内容：<textarea id="contenttitle" adjust-position="true" auto-height="true"/>
		</view>
		<button class="submitbtn" @click="submithealth()">提交</button>
	 -->
	
		
		<view class="login-from">
			<form @submit="formSubmit">
			    <!--标题-->
				
			    <view class="inputView"> 
					 <label class="uni-list-cell-left">标题:</label>
					 <view class="inputName">
						 <input class="inputText" name="title" bindinput="usernameInput" /> 
					 </view>
					
			    </view>
			
			    <view class="line"></view>
				
				 
				<view >
					<view class="uni-list-cell-left">内容:</view>
					<view class="uni-textarea">
						<textarea class="uni-input" name="content" placeholder-style="color:#999999" placeholder="请输入..."/>
					</view>
				</view>
				
				
				<view class="uni-btn-v">
			        <button form-type="submit">提交</button>
			    </view>
			</form>
		</view>
	</view>
</template>

<script>
	import { updateList } from '@/api/index.js'
	export default {
		data() {
			return {
				
			}
		},
		methods:{
			formSubmit(val){
				let param = {
					title: '',
					content: '',
					createTime: '',
					likeCount: 0,
					viewCount: 0
				}
				param.title = val.detail.value.title
				param.content =val.detail.value.content
				if(!param.title) {
					uni.showToast({
						title: '请输入标题',
						icon: 'none'
					})
				} else if (!param.content) {
					uni.showToast({
						title: '请输入内容',
						icon: 'none'
					})
				} else {
					updateList(param).then(res => {
						if(res.code !== 200) {
							uni.showToast({
								title: res.message,
								icon: 'none'
							})
							return
						}
						uni.showToast({
							title: res.message,
							icon: 'none'
						})
						uni.navigateBack({
							delta: 1
						})
					})
				}
				console.log(val.detail.value)
			}
		}
	}
</script>

<style>
	.container {
		height: 100%; 
		 display: flex; 
		 flex-direction: column; 
		 padding: 0; 
		 box-sizing: border-box; 
		/* background: linear-gradient(top, #4a8d9c, #705271); */
	}
	/*表单内容*/
	.login-from { 
		 flex: auto; 
		 height:100%; 
		 padding: 60rpx;
		 display: flex;
		 align-items: center;
		 justify-content: center;
	}
	.inputView {
		 display: flex;
		 flex-direction: row;
		 align-items: center;
	} 
	.inputName {
		border:1px solid #999999;
		border-radius:10px;
		width: 85%;
		height: 80rpx;
		display: flex;
		align-items: center;
	}
	 
	.inputText { 
	 margin-left: 30rpx; 
	 color: #4a8d9c; 
	 font-size: medium;
	 
	} 
	.line { 
	 margin-top: 20rpx; 
	} 
	
	.uni-list-cell-left {
		padding-right: 20rpx;
		color: #545454;
		font-size: medium;
		white-space: pre-wrap;
	}
	.uni-input {
		color: #4a8d9c;
		font-size: medium;
		padding-left: 20rpx;
	}
	.uni-textarea {
		border:1px solid #999999;
		border-radius:10px;
		margin-top: 10rpx;
		padding: 10rpx;
	}
	button {
	  width: 100%;
	  margin-top: 100rpx;
	  background-color: rgba(74,141,156,0.9);
	  color: white;
	  border-radius: 98rpx;
	  display: flex;
	  flex-direction: row;
	  align-items: center;
	  justify-content: center;
	}
	
	
	button::after {
	  border-radius: 98rpx;
	  border: 0; 
	}
	.uni-btn-v{
		margin-top: 50rpx;
	}
</style>
